using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using UpdaterManagement.Data;
using Microsoft.AspNetCore.Authorization;

namespace UpdaterManagement.Controllers
{
    [Authorize]
    public class HomeController : Controller
    {
        private readonly ApplicationDbContext _context;

        public HomeController(ApplicationDbContext context)
        {
            _context = context;
        }

        public async Task<IActionResult> Index()
        {
            ViewBag.ProductCount = await _context.Products.CountAsync();
            ViewBag.VersionCount = await _context.VersionReleases.CountAsync();
            ViewBag.EnterpriseCount = await _context.Enterprises.Where(e => e.IsActive).CountAsync();
            ViewBag.DeployedCount = await _context.DeployedApplications.CountAsync();
            
            return View();
        }
    }
}